import config from '@/config/config.js';
import axios from "axios";

const warehouseAreaRequest = {
    loadWarehouseAreaList(searchWarehouse,pageNum,limit,callback){
        let url = config.warehouseBaseUrl + "/warehouseArea/list?pageNum=" + pageNum + "&limit=" + limit + "&warehouseId=" + searchWarehouse.warehouseId
        if (searchWarehouse.warehouseAreaName){
            url += "&warehouseAreaName=" + searchWarehouse.warehouseAreaName
        }
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data.data)
        })
    },
    loadSearchInfo(warehouseAreaId,warehouseId,callback){
        let url = config.warehouseBaseUrl + "/warehouseArea/updateInfo?warehouseAreaId=" + warehouseAreaId + "&warehouseId=" + warehouseId
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    deleteWarehouseArea(warehouseAreaId,warehouseId,callback){
        let url = config.warehouseBaseUrl + "/warehouseArea/delete?warehouseAreaId=" + warehouseAreaId + "&warehouseId=" + warehouseId
        axios.delete(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    updateWarehouseArea(updateWarehouseArea,callback){
        let url = config.warehouseBaseUrl + "/warehouseArea/update"
        axios.put(url,updateWarehouseArea,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    insertWarehouseArea(insertWarehouseArea,callback){
        let url =config.warehouseBaseUrl + "/warehouseArea/insert"
        axios.post(url,insertWarehouseArea,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    }
}
export default warehouseAreaRequest;